namespace CSharpPro._1020;

public class Demo1
{
    public void BubbleSort(int[] arr)
    {
        
        if (arr == null || arr.Length <= 1)
            return;
        int length = arr.Length;
        for (int i = 0; i < length - 1; i++)
        {
            for (int j = 0; j < length - 1 - i; j++)
            {
                if (arr[j] > arr[j + 1])
                {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }

        foreach (int i in arr ) 
            Console.Write(i + " ");
        {
            
        }
    }
}
  

